/**
 *
 * @param {Array} menulist
 * @param {Array} allroutes
 * @param {Array}
 */

const recursionRoutes = (menuList = [], allRoutes = []) => {
  let userRoutes = [];
  menuList.forEach((item) => {
    allRoutes.forEach((routes) => {
      if (item.name === routes.meta.name) {
        if (item.children && item.children.length > 0) {
          routes.children = recursionRoutes(item.children, routes.children);
        }
        userRoutes.push(routes);
      }
    });
  });
  return userRoutes;
};

export default recursionRoutes;
